﻿Imports System.Data
Imports System.Data.SqlClient
Imports Sistema_InformacionNaviera.BE
Imports Sistema_InformacionNaviera.DALC
Imports Sistema_InformacionNavier.UTIL



Public Class BillOfLadingImpoDALC


    Public Function InsertarBLimportacion(ByVal objBLImpoBE As BillOfLadingImpoBE, ByRef bExito As Boolean, ByRef sMensaje As String) As Boolean

        Dim arrSqlParameter(57) As SqlParameter

        Try

            arrSqlParameter(0) = New SqlParameter()
            arrSqlParameter(0).ParameterName = "@KVJE"
            arrSqlParameter(0).SqlDbType = SqlDbType.Int
            arrSqlParameter(0).Direction = ParameterDirection.Input
            arrSqlParameter(0).Value = objBLImpoBE.KVJE

            arrSqlParameter(1) = New SqlParameter()
            arrSqlParameter(1).ParameterName = "@KBLM"
            arrSqlParameter(1).SqlDbType = SqlDbType.Int
            arrSqlParameter(1).Direction = ParameterDirection.Input
            arrSqlParameter(1).Value = objBLImpoBE.KBLM

            arrSqlParameter(2) = New SqlParameter()
            arrSqlParameter(2).ParameterName = "@TOPE"
            arrSqlParameter(2).SqlDbType = SqlDbType.Char
            arrSqlParameter(2).Size = 1
            arrSqlParameter(2).Direction = ParameterDirection.Input
            arrSqlParameter(2).Value = objBLImpoBE.TOPE

            arrSqlParameter(3) = New SqlParameter()
            arrSqlParameter(3).ParameterName = "@Nume"
            arrSqlParameter(3).SqlDbType = SqlDbType.VarChar
            arrSqlParameter(3).Size = 20
            arrSqlParameter(3).Direction = ParameterDirection.Input
            arrSqlParameter(3).Value = objBLImpoBE.Nume

            arrSqlParameter(4) = New SqlParameter()
            arrSqlParameter(4).ParameterName = "@Tibl"
            arrSqlParameter(4).SqlDbType = SqlDbType.VarChar
            arrSqlParameter(4).Size = 1
            arrSqlParameter(4).Direction = ParameterDirection.Input
            arrSqlParameter(4).Value = objBLImpoBE.Tibl

            arrSqlParameter(5) = New SqlParameter()
            arrSqlParameter(5).ParameterName = "@Lemi"
            arrSqlParameter(5).SqlDbType = SqlDbType.VarChar
            arrSqlParameter(5).Size = 3
            arrSqlParameter(5).Direction = ParameterDirection.Input
            arrSqlParameter(5).Value = objBLImpoBE.Lemi

            arrSqlParameter(6) = New SqlParameter()
            arrSqlParameter(6).ParameterName = "@Femi"
            arrSqlParameter(6).SqlDbType = SqlDbType.VarChar
            arrSqlParameter(6).Size = 10
            arrSqlParameter(6).Direction = ParameterDirection.Input
            arrSqlParameter(6).Value = objBLImpoBE.Femi

            arrSqlParameter(7) = New SqlParameter()
            arrSqlParameter(7).ParameterName = "@Emba"
            arrSqlParameter(7).SqlDbType = SqlDbType.VarChar
            arrSqlParameter(7).Size = 6
            arrSqlParameter(7).Direction = ParameterDirection.Input
            arrSqlParameter(7).Value = objBLImpoBE.Emba

            arrSqlParameter(8) = New SqlParameter()
            arrSqlParameter(8).ParameterName = "@Csne"
            arrSqlParameter(8).SqlDbType = SqlDbType.VarChar
            arrSqlParameter(8).Size = 6
            arrSqlParameter(8).Direction = ParameterDirection.Input
            arrSqlParameter(8).Value = objBLImpoBE.Csne

            arrSqlParameter(9) = New SqlParameter()
            arrSqlParameter(9).ParameterName = "@Noti"
            arrSqlParameter(9).SqlDbType = SqlDbType.VarChar
            arrSqlParameter(9).Size = 6
            arrSqlParameter(9).Direction = ParameterDirection.Input
            arrSqlParameter(9).Value = objBLImpoBE.Noti

            arrSqlParameter(10) = New SqlParameter()
            arrSqlParameter(10).ParameterName = "@Not2"
            arrSqlParameter(10).SqlDbType = SqlDbType.VarChar
            arrSqlParameter(10).Size = 6
            arrSqlParameter(10).Direction = ParameterDirection.Input
            arrSqlParameter(10).Value = objBLImpoBE.Not2

            arrSqlParameter(11) = New SqlParameter()
            arrSqlParameter(11).ParameterName = "@Fwdr"
            arrSqlParameter(11).SqlDbType = SqlDbType.VarChar
            arrSqlParameter(11).Size = 6
            arrSqlParameter(11).Direction = ParameterDirection.Input
            arrSqlParameter(11).Value = objBLImpoBE.Fwdr

            arrSqlParameter(12) = New SqlParameter()
            arrSqlParameter(12).ParameterName = "@Agad"
            arrSqlParameter(12).SqlDbType = SqlDbType.VarChar
            arrSqlParameter(12).Size = 6
            arrSqlParameter(12).Direction = ParameterDirection.Input
            arrSqlParameter(12).Value = objBLImpoBE.Agad

            arrSqlParameter(13) = New SqlParameter()
            arrSqlParameter(13).ParameterName = "@Line"
            arrSqlParameter(13).SqlDbType = SqlDbType.VarChar
            arrSqlParameter(13).Size = 3
            arrSqlParameter(13).Direction = ParameterDirection.Input
            arrSqlParameter(13).Value = objBLImpoBE.Line

            arrSqlParameter(14) = New SqlParameter()
            arrSqlParameter(14).ParameterName = "@Ptoo"
            arrSqlParameter(14).SqlDbType = SqlDbType.VarChar
            arrSqlParameter(14).Size = 3
            arrSqlParameter(14).Direction = ParameterDirection.Input
            arrSqlParameter(14).Value = objBLImpoBE.Ptoo

            arrSqlParameter(15) = New SqlParameter()
            arrSqlParameter(15).ParameterName = "@Ptoe"
            arrSqlParameter(15).SqlDbType = SqlDbType.VarChar
            arrSqlParameter(15).Size = 3
            arrSqlParameter(15).Direction = ParameterDirection.Input
            arrSqlParameter(15).Value = objBLImpoBE.Ptoe

            arrSqlParameter(16) = New SqlParameter()
            arrSqlParameter(16).ParameterName = "@Dfin"
            arrSqlParameter(16).SqlDbType = SqlDbType.VarChar
            arrSqlParameter(16).Size = 3
            arrSqlParameter(16).Direction = ParameterDirection.Input
            arrSqlParameter(16).Value = objBLImpoBE.Dfin

            arrSqlParameter(17) = New SqlParameter()
            arrSqlParameter(17).ParameterName = "@Dfi2"
            arrSqlParameter(17).SqlDbType = SqlDbType.VarChar
            arrSqlParameter(17).Size = 3
            arrSqlParameter(17).Direction = ParameterDirection.Input
            arrSqlParameter(17).Value = objBLImpoBE.Dfi2


            arrSqlParameter(18) = New SqlParameter()
            arrSqlParameter(18).ParameterName = "@Dpte"
            arrSqlParameter(18).SqlDbType = SqlDbType.VarChar
            arrSqlParameter(18).Size = 50
            arrSqlParameter(18).Direction = ParameterDirection.Input
            arrSqlParameter(18).Value = objBLImpoBE.Dpte

            arrSqlParameter(19) = New SqlParameter()
            arrSqlParameter(19).ParameterName = "@Dpto"
            arrSqlParameter(19).SqlDbType = SqlDbType.VarChar
            arrSqlParameter(19).Size = 50
            arrSqlParameter(19).Direction = ParameterDirection.Input
            arrSqlParameter(19).Value = objBLImpoBE.Dpto

            arrSqlParameter(20) = New SqlParameter()
            arrSqlParameter(20).ParameterName = "@Dptd"
            arrSqlParameter(20).SqlDbType = SqlDbType.VarChar
            arrSqlParameter(20).Size = 50
            arrSqlParameter(20).Direction = ParameterDirection.Input
            arrSqlParameter(20).Value = objBLImpoBE.Dptd

            arrSqlParameter(21) = New SqlParameter()
            arrSqlParameter(21).ParameterName = "@Ddfi"
            arrSqlParameter(21).SqlDbType = SqlDbType.VarChar
            arrSqlParameter(21).Size = 50
            arrSqlParameter(21).Direction = ParameterDirection.Input
            arrSqlParameter(21).Value = objBLImpoBE.Ddfi

            arrSqlParameter(22) = New SqlParameter()
            arrSqlParameter(22).ParameterName = "@Ddf2"
            arrSqlParameter(22).SqlDbType = SqlDbType.VarChar
            arrSqlParameter(22).Size = 50
            arrSqlParameter(22).Direction = ParameterDirection.Input
            arrSqlParameter(22).Value = objBLImpoBE.Ddf2

            arrSqlParameter(23) = New SqlParameter()
            arrSqlParameter(23).ParameterName = "@Fomt"
            arrSqlParameter(23).SqlDbType = SqlDbType.VarChar
            arrSqlParameter(23).Size = 1
            arrSqlParameter(23).Direction = ParameterDirection.Input
            arrSqlParameter(23).Value = objBLImpoBE.Fomt

            arrSqlParameter(24) = New SqlParameter()
            arrSqlParameter(24).ParameterName = "@OBSE"
            arrSqlParameter(24).SqlDbType = SqlDbType.VarChar
            arrSqlParameter(24).Size = 400
            arrSqlParameter(24).Direction = ParameterDirection.Input
            arrSqlParameter(24).Value = objBLImpoBE.OBSE

            arrSqlParameter(25) = New SqlParameter()
            arrSqlParameter(25).ParameterName = "@Tfpf"
            arrSqlParameter(25).SqlDbType = SqlDbType.VarChar
            arrSqlParameter(25).Size = 400
            arrSqlParameter(25).Direction = ParameterDirection.Input
            arrSqlParameter(25).Value = objBLImpoBE.Tfpf

            arrSqlParameter(26) = New SqlParameter()
            arrSqlParameter(26).ParameterName = "@Tfpt"
            arrSqlParameter(26).SqlDbType = SqlDbType.Float
            arrSqlParameter(26).Direction = ParameterDirection.Input
            arrSqlParameter(26).Value = objBLImpoBE.Tfpt

            arrSqlParameter(27) = New SqlParameter()
            arrSqlParameter(27).ParameterName = "@Tfcf"
            arrSqlParameter(27).SqlDbType = SqlDbType.Float
            arrSqlParameter(27).Direction = ParameterDirection.Input
            arrSqlParameter(27).Value = objBLImpoBE.Tfcf

            arrSqlParameter(28) = New SqlParameter()
            arrSqlParameter(28).ParameterName = "@Tfct"
            arrSqlParameter(28).SqlDbType = SqlDbType.Float
            arrSqlParameter(28).Direction = ParameterDirection.Input
            arrSqlParameter(28).Value = objBLImpoBE.Tfct

            arrSqlParameter(29) = New SqlParameter()
            arrSqlParameter(29).ParameterName = "@CFLE"
            arrSqlParameter(29).SqlDbType = SqlDbType.Char
            arrSqlParameter(29).Size = 1
            arrSqlParameter(29).Direction = ParameterDirection.Input
            arrSqlParameter(29).Value = objBLImpoBE.CFLE

            arrSqlParameter(30) = New SqlParameter()
            arrSqlParameter(30).ParameterName = "@Unid"
            arrSqlParameter(30).SqlDbType = SqlDbType.Int
            arrSqlParameter(30).Direction = ParameterDirection.Input
            arrSqlParameter(30).Value = objBLImpoBE.Unid

            arrSqlParameter(31) = New SqlParameter()
            arrSqlParameter(31).ParameterName = "@Csue"
            arrSqlParameter(31).SqlDbType = SqlDbType.Int
            arrSqlParameter(31).Direction = ParameterDirection.Input
            arrSqlParameter(31).Value = objBLImpoBE.Csue

            arrSqlParameter(32) = New SqlParameter()
            arrSqlParameter(32).ParameterName = "@Pkgs"
            arrSqlParameter(32).SqlDbType = SqlDbType.Int
            arrSqlParameter(32).Direction = ParameterDirection.Input
            arrSqlParameter(32).Value = objBLImpoBE.Pkgs

            arrSqlParameter(33) = New SqlParameter()
            arrSqlParameter(33).ParameterName = "@Tafle"
            arrSqlParameter(33).SqlDbType = SqlDbType.Float
            arrSqlParameter(33).Direction = ParameterDirection.Input
            arrSqlParameter(33).Value = objBLImpoBE.Tafle

            arrSqlParameter(34) = New SqlParameter()
            arrSqlParameter(34).ParameterName = "@Tathc"
            arrSqlParameter(34).SqlDbType = SqlDbType.Float
            arrSqlParameter(34).Direction = ParameterDirection.Input
            arrSqlParameter(34).Value = objBLImpoBE.Tathc

            arrSqlParameter(35) = New SqlParameter()
            arrSqlParameter(35).ParameterName = "@ESTA"
            arrSqlParameter(35).SqlDbType = SqlDbType.Bit
            arrSqlParameter(35).Direction = ParameterDirection.Input
            arrSqlParameter(35).Value = objBLImpoBE.ESTA

            arrSqlParameter(36) = New SqlParameter()
            arrSqlParameter(36).ParameterName = "@Agge"
            arrSqlParameter(36).SqlDbType = SqlDbType.VarChar
            arrSqlParameter(36).Size = 6
            arrSqlParameter(36).Direction = ParameterDirection.Input
            arrSqlParameter(36).Value = objBLImpoBE.Agge

            arrSqlParameter(37) = New SqlParameter()
            arrSqlParameter(37).ParameterName = "@Serv"
            arrSqlParameter(37).SqlDbType = SqlDbType.VarChar
            arrSqlParameter(37).Size = 3
            arrSqlParameter(37).Direction = ParameterDirection.Input
            arrSqlParameter(37).Value = objBLImpoBE.Serv

            arrSqlParameter(38) = New SqlParameter()
            arrSqlParameter(38).ParameterName = "@Norig"
            arrSqlParameter(38).SqlDbType = SqlDbType.Int
            arrSqlParameter(38).Direction = ParameterDirection.Input
            arrSqlParameter(38).Value = objBLImpoBE.Norig

            arrSqlParameter(39) = New SqlParameter()
            arrSqlParameter(39).ParameterName = "@Dtot"
            arrSqlParameter(39).SqlDbType = SqlDbType.VarChar
            arrSqlParameter(39).Size = 40
            arrSqlParameter(39).Direction = ParameterDirection.Input
            arrSqlParameter(39).Value = objBLImpoBE.Dtot

            arrSqlParameter(40) = New SqlParameter()
            arrSqlParameter(40).ParameterName = "@Lpfp"
            arrSqlParameter(40).SqlDbType = SqlDbType.VarChar
            arrSqlParameter(40).Size = 30
            arrSqlParameter(40).Direction = ParameterDirection.Input
            arrSqlParameter(40).Value = objBLImpoBE.Lpfp

            arrSqlParameter(41) = New SqlParameter()
            arrSqlParameter(41).ParameterName = "@Lpfc"
            arrSqlParameter(41).SqlDbType = SqlDbType.VarChar
            arrSqlParameter(41).Size = 30
            arrSqlParameter(41).Direction = ParameterDirection.Input
            arrSqlParameter(41).Value = objBLImpoBE.Lpfc

            arrSqlParameter(42) = New SqlParameter()
            arrSqlParameter(42).ParameterName = "@Talm"
            arrSqlParameter(42).SqlDbType = SqlDbType.VarChar
            arrSqlParameter(42).Size = 3
            arrSqlParameter(42).Direction = ParameterDirection.Input
            arrSqlParameter(42).Value = objBLImpoBE.Talm

            arrSqlParameter(43) = New SqlParameter()
            arrSqlParameter(43).ParameterName = "@Agdo"
            arrSqlParameter(43).SqlDbType = SqlDbType.VarChar
            arrSqlParameter(43).Size = 6
            arrSqlParameter(43).Direction = ParameterDirection.Input
            arrSqlParameter(43).Value = objBLImpoBE.Agdo

            arrSqlParameter(44) = New SqlParameter()
            arrSqlParameter(44).ParameterName = "@Tdes"
            arrSqlParameter(44).SqlDbType = SqlDbType.VarChar
            arrSqlParameter(44).Size = 1
            arrSqlParameter(44).Direction = ParameterDirection.Input
            arrSqlParameter(44).Value = objBLImpoBE.Tdes

            arrSqlParameter(45) = New SqlParameter()
            arrSqlParameter(45).ParameterName = "@Cond"
            arrSqlParameter(45).SqlDbType = SqlDbType.VarChar
            arrSqlParameter(45).Size = 1
            arrSqlParameter(45).Direction = ParameterDirection.Input
            arrSqlParameter(45).Value = objBLImpoBE.Cond

            arrSqlParameter(46) = New SqlParameter()
            arrSqlParameter(46).ParameterName = "@OpeLog"
            arrSqlParameter(46).SqlDbType = SqlDbType.VarChar
            arrSqlParameter(46).Size = 6
            arrSqlParameter(46).Direction = ParameterDirection.Input
            arrSqlParameter(46).Value = objBLImpoBE.OpeLog

            arrSqlParameter(47) = New SqlParameter()
            arrSqlParameter(47).ParameterName = "@CUSU"
            arrSqlParameter(47).SqlDbType = SqlDbType.VarChar
            arrSqlParameter(47).Size = 15
            arrSqlParameter(47).Direction = ParameterDirection.Input
            arrSqlParameter(47).Value = objBLImpoBE.CUSU

            arrSqlParameter(48) = New SqlParameter()
            arrSqlParameter(48).ParameterName = "@TfcfInt"
            arrSqlParameter(48).SqlDbType = SqlDbType.Float
            arrSqlParameter(48).Direction = ParameterDirection.Input
            arrSqlParameter(48).Value = objBLImpoBE.TfcfInt

            arrSqlParameter(49) = New SqlParameter()
            arrSqlParameter(49).ParameterName = "@TfctInt"
            arrSqlParameter(49).SqlDbType = SqlDbType.Float
            arrSqlParameter(49).Direction = ParameterDirection.Input
            arrSqlParameter(49).Value = objBLImpoBE.TfctInt

            arrSqlParameter(50) = New SqlParameter()
            arrSqlParameter(50).ParameterName = "@Ptod"
            arrSqlParameter(50).SqlDbType = SqlDbType.VarChar
            arrSqlParameter(50).Direction = ParameterDirection.Input
            arrSqlParameter(50).Value = objBLImpoBE.Ptod

            arrSqlParameter(51) = New SqlParameter()
            arrSqlParameter(51).ParameterName = "@Ent_ObsEmb"
            arrSqlParameter(51).SqlDbType = SqlDbType.VarChar
            arrSqlParameter(51).Size = 6
            arrSqlParameter(51).Direction = ParameterDirection.Input
            arrSqlParameter(51).Value = objBLImpoBE.Ent_ObsEmb

            arrSqlParameter(52) = New SqlParameter()
            arrSqlParameter(52).ParameterName = "@Ent_ObsCons"
            arrSqlParameter(52).SqlDbType = SqlDbType.VarChar
            arrSqlParameter(52).Size = 6
            arrSqlParameter(52).Direction = ParameterDirection.Input
            arrSqlParameter(52).Value = objBLImpoBE.Ent_ObsCons

            arrSqlParameter(53) = New SqlParameter()
            arrSqlParameter(53).ParameterName = "@Ent_ObsDoc"
            arrSqlParameter(53).SqlDbType = SqlDbType.VarChar
            arrSqlParameter(53).Size = 6
            arrSqlParameter(53).Direction = ParameterDirection.Input
            arrSqlParameter(53).Value = objBLImpoBE.Ent_ObsDoc

            arrSqlParameter(54) = New SqlParameter()
            arrSqlParameter(54).ParameterName = "@Bli_Flag"
            arrSqlParameter(54).SqlDbType = SqlDbType.Char
            arrSqlParameter(54).Size = 1
            arrSqlParameter(54).Direction = ParameterDirection.Input
            arrSqlParameter(54).Value = objBLImpoBE.Bli_Flag

            arrSqlParameter(55) = New SqlParameter()
            arrSqlParameter(55).ParameterName = "@Bli_PtoDsc1"
            arrSqlParameter(55).SqlDbType = SqlDbType.Char
            arrSqlParameter(55).Size = 1
            arrSqlParameter(55).Direction = ParameterDirection.Input
            arrSqlParameter(55).Value = objBLImpoBE.CodPto_Desc1

            arrSqlParameter(56) = New SqlParameter()
            arrSqlParameter(56).ParameterName = "@Bli_PtoDsc2"
            arrSqlParameter(56).SqlDbType = SqlDbType.Char
            arrSqlParameter(56).Size = 1
            arrSqlParameter(56).Direction = ParameterDirection.Input
            arrSqlParameter(56).Value = objBLImpoBE.CodPto_Desc2

            arrSqlParameter(57) = New SqlParameter()
            arrSqlParameter(57).ParameterName = "@Bli_Fvb"
            arrSqlParameter(57).SqlDbType = SqlDbType.VarChar
            arrSqlParameter(57).Size = 10
            arrSqlParameter(57).Direction = ParameterDirection.Input
            arrSqlParameter(57).Value = objBLImpoBE.Bli_Fvb


            Dim oDatos As New AccesoDatos()
            oDatos.EjecutaSP("Documentacion_BLImpo_Edicion", bExito, sMensaje, arrSqlParameter)

            Return bExito

        Catch ex As Exception
            Throw
        End Try

    End Function


    Public Function InsertarBlImpoFlete(ByVal objBLImpoBE As BillOfLadingImpoBE, ByRef bExito As Boolean, ByRef sMensaje As String) As Boolean

        Dim arrSqlParameter(16) As SqlParameter

        Try

            arrSqlParameter(0) = New SqlParameter()
            arrSqlParameter(0).ParameterName = "@Bef_Kvje"
            arrSqlParameter(0).SqlDbType = SqlDbType.Int
            arrSqlParameter(0).Direction = ParameterDirection.Input
            arrSqlParameter(0).Value = objBLImpoBE.KVJE

            arrSqlParameter(1) = New SqlParameter()
            arrSqlParameter(1).ParameterName = "@Bef_Kble"
            arrSqlParameter(1).SqlDbType = SqlDbType.Int
            arrSqlParameter(1).Direction = ParameterDirection.Input
            arrSqlParameter(1).Value = objBLImpoBE.KBLM

            arrSqlParameter(2) = New SqlParameter()
            arrSqlParameter(2).ParameterName = "@TOPE"
            arrSqlParameter(2).SqlDbType = SqlDbType.Char
            arrSqlParameter(2).Size = 1
            arrSqlParameter(2).Direction = ParameterDirection.Input
            arrSqlParameter(2).Value = objBLImpoBE.TOPE

            'ID del registro
            arrSqlParameter(3) = New SqlParameter()
            arrSqlParameter(3).ParameterName = "@Bef_Kfle"
            arrSqlParameter(3).SqlDbType = SqlDbType.Int
            arrSqlParameter(3).Direction = ParameterDirection.Input
            arrSqlParameter(3).Value = objBLImpoBE.Bef_Kfle

            arrSqlParameter(4) = New SqlParameter()
            arrSqlParameter(4).ParameterName = "@Bef_Tari"
            arrSqlParameter(4).SqlDbType = SqlDbType.VarChar
            arrSqlParameter(4).Size = 10
            arrSqlParameter(4).Direction = ParameterDirection.Input
            arrSqlParameter(4).Value = objBLImpoBE.Bef_Tari

            arrSqlParameter(5) = New SqlParameter()
            arrSqlParameter(5).ParameterName = "@Bef_Umed"
            arrSqlParameter(5).SqlDbType = SqlDbType.VarChar
            arrSqlParameter(5).Size = 3
            arrSqlParameter(5).Direction = ParameterDirection.Input
            arrSqlParameter(5).Value = objBLImpoBE.Bef_Umed

            arrSqlParameter(6) = New SqlParameter()
            arrSqlParameter(6).ParameterName = "@Bef_Cant"
            arrSqlParameter(6).SqlDbType = SqlDbType.Float
            arrSqlParameter(6).Direction = ParameterDirection.Input
            arrSqlParameter(6).Value = objBLImpoBE.Bef_Cant

            arrSqlParameter(7) = New SqlParameter()
            arrSqlParameter(7).ParameterName = "@Bef_Tfle"
            arrSqlParameter(7).SqlDbType = SqlDbType.Float
            arrSqlParameter(7).Direction = ParameterDirection.Input
            arrSqlParameter(7).Value = objBLImpoBE.Bef_Tfle

            arrSqlParameter(8) = New SqlParameter()
            arrSqlParameter(8).ParameterName = "@Bef_Tmon"
            arrSqlParameter(8).SqlDbType = SqlDbType.Float
            arrSqlParameter(8).Direction = ParameterDirection.Input
            arrSqlParameter(8).Value = objBLImpoBE.Bef_Tmon

            arrSqlParameter(9) = New SqlParameter()
            arrSqlParameter(9).ParameterName = "@Bef_Tpag"
            arrSqlParameter(9).SqlDbType = SqlDbType.VarChar
            arrSqlParameter(9).Size = 1
            arrSqlParameter(9).Direction = ParameterDirection.Input
            arrSqlParameter(9).Value = objBLImpoBE.Bef_Tpag

            arrSqlParameter(10) = New SqlParameter()
            arrSqlParameter(10).ParameterName = "@Bef_Mone"
            arrSqlParameter(10).SqlDbType = SqlDbType.VarChar
            arrSqlParameter(10).Size = 3
            arrSqlParameter(10).Direction = ParameterDirection.Input
            arrSqlParameter(10).Value = objBLImpoBE.Bef_Mone

            arrSqlParameter(11) = New SqlParameter()
            arrSqlParameter(11).ParameterName = "@Bef_Dfle"
            arrSqlParameter(11).SqlDbType = SqlDbType.VarChar
            arrSqlParameter(11).Size = 60
            arrSqlParameter(11).Direction = ParameterDirection.Input
            arrSqlParameter(11).Value = objBLImpoBE.Bef_Dfle

            arrSqlParameter(12) = New SqlParameter()
            arrSqlParameter(12).ParameterName = "@Bef_Lpag"
            arrSqlParameter(12).SqlDbType = SqlDbType.VarChar
            arrSqlParameter(12).Size = 3
            arrSqlParameter(12).Direction = ParameterDirection.Input
            arrSqlParameter(12).Value = objBLImpoBE.Bef_Lpag

            arrSqlParameter(13) = New SqlParameter()
            arrSqlParameter(13).ParameterName = "@Bef_Ucre"
            arrSqlParameter(13).SqlDbType = SqlDbType.VarChar
            arrSqlParameter(13).Size = 15
            arrSqlParameter(13).Direction = ParameterDirection.Input
            arrSqlParameter(13).Value = objBLImpoBE.Ucre

            arrSqlParameter(14) = New SqlParameter()
            arrSqlParameter(14).ParameterName = "@Bef_Umod"
            arrSqlParameter(14).SqlDbType = SqlDbType.VarChar
            arrSqlParameter(14).Size = 15
            arrSqlParameter(14).Direction = ParameterDirection.Input
            arrSqlParameter(14).Value = objBLImpoBE.Umod

            arrSqlParameter(15) = New SqlParameter()
            arrSqlParameter(15).ParameterName = "@Bef_PC"
            arrSqlParameter(15).SqlDbType = SqlDbType.VarChar
            arrSqlParameter(15).Size = 15
            arrSqlParameter(15).Direction = ParameterDirection.Input
            arrSqlParameter(15).Value = objBLImpoBE.Bef_PC

            arrSqlParameter(16) = New SqlParameter()
            arrSqlParameter(16).ParameterName = "@Bec_Est"
            arrSqlParameter(16).SqlDbType = SqlDbType.VarChar
            arrSqlParameter(16).Size = 1
            arrSqlParameter(16).Direction = ParameterDirection.Input
            arrSqlParameter(16).Value = objBLImpoBE.Bec_Esta


            Dim oDatos As New AccesoDatos()

            oDatos.EjecutaSP("SP_BlsFletes_Ins", bExito, sMensaje, arrSqlParameter)

            Return bExito

        Catch ex As Exception
            Throw
        End Try

    End Function


    Public Function InsertarBlImpoContenedor(ByVal objBLImpoBE As BillOfLadingImpoBE, ByRef bExito As Boolean, ByRef sMensaje As String) As Boolean

        Dim arrSqlParameter(29) As SqlParameter

        Try

            arrSqlParameter(0) = New SqlParameter()
            arrSqlParameter(0).ParameterName = "@Bec_Kvje"
            arrSqlParameter(0).SqlDbType = SqlDbType.Int
            arrSqlParameter(0).Direction = ParameterDirection.Input
            arrSqlParameter(0).Value = objBLImpoBE.KVJE

            'id
            arrSqlParameter(1) = New SqlParameter()
            arrSqlParameter(1).ParameterName = "@Bec_Kbli"
            arrSqlParameter(1).SqlDbType = SqlDbType.Int
            arrSqlParameter(1).Direction = ParameterDirection.Input
            arrSqlParameter(1).Value = objBLImpoBE.KBLM

            arrSqlParameter(2) = New SqlParameter()
            arrSqlParameter(2).ParameterName = "@TOPE"
            arrSqlParameter(2).SqlDbType = SqlDbType.Char
            arrSqlParameter(2).Size = 1
            arrSqlParameter(2).Direction = ParameterDirection.Input
            arrSqlParameter(2).Value = objBLImpoBE.TOPE

            arrSqlParameter(3) = New SqlParameter()
            arrSqlParameter(3).ParameterName = "@Bec_Pref"
            arrSqlParameter(3).SqlDbType = SqlDbType.VarChar
            arrSqlParameter(3).Size = 4
            arrSqlParameter(3).Direction = ParameterDirection.Input
            arrSqlParameter(3).Value = objBLImpoBE.Bec_Pref

            arrSqlParameter(4) = New SqlParameter()
            arrSqlParameter(4).ParameterName = "@Bec_nume"
            arrSqlParameter(4).SqlDbType = SqlDbType.VarChar
            arrSqlParameter(4).Size = 7
            arrSqlParameter(4).Direction = ParameterDirection.Input
            arrSqlParameter(4).Value = objBLImpoBE.Bec_nume

            arrSqlParameter(5) = New SqlParameter()
            arrSqlParameter(5).ParameterName = "@Bec_Tipo"
            arrSqlParameter(5).SqlDbType = SqlDbType.VarChar
            arrSqlParameter(5).Size = 3
            arrSqlParameter(5).Direction = ParameterDirection.Input
            arrSqlParameter(5).Value = objBLImpoBE.Bec_Tipo

            arrSqlParameter(6) = New SqlParameter()
            arrSqlParameter(6).ParameterName = "@Bec_Pies"
            arrSqlParameter(6).SqlDbType = SqlDbType.Int
            arrSqlParameter(6).Direction = ParameterDirection.Input
            arrSqlParameter(6).Value = objBLImpoBE.Bec_Pies

            arrSqlParameter(7) = New SqlParameter()
            arrSqlParameter(7).ParameterName = "@Bec_Dpto"
            arrSqlParameter(7).SqlDbType = SqlDbType.VarChar
            arrSqlParameter(7).Size = 15
            arrSqlParameter(7).Direction = ParameterDirection.Input
            arrSqlParameter(7).Value = objBLImpoBE.Bec_Dpto

            arrSqlParameter(8) = New SqlParameter()
            arrSqlParameter(8).ParameterName = "@Bec_Volu"
            arrSqlParameter(8).SqlDbType = SqlDbType.Float
            arrSqlParameter(8).Direction = ParameterDirection.Input
            arrSqlParameter(8).Value = objBLImpoBE.Bec_Volu

            arrSqlParameter(9) = New SqlParameter()
            arrSqlParameter(9).ParameterName = "@Bec_Peso"
            arrSqlParameter(9).SqlDbType = SqlDbType.Float
            arrSqlParameter(9).Direction = ParameterDirection.Input
            arrSqlParameter(9).Value = objBLImpoBE.Bec_Peso

            arrSqlParameter(10) = New SqlParameter()
            arrSqlParameter(10).ParameterName = "@Bec_Tara"
            arrSqlParameter(10).SqlDbType = SqlDbType.Float
            arrSqlParameter(10).Direction = ParameterDirection.Input
            arrSqlParameter(10).Value = objBLImpoBE.Bec_Tara

            arrSqlParameter(11) = New SqlParameter()
            arrSqlParameter(11).ParameterName = "@Bec_Cond"
            arrSqlParameter(11).SqlDbType = SqlDbType.Char
            arrSqlParameter(11).Size = 2
            arrSqlParameter(11).Direction = ParameterDirection.Input
            arrSqlParameter(11).Value = objBLImpoBE.Bec_Cond

            arrSqlParameter(12) = New SqlParameter()
            arrSqlParameter(12).ParameterName = "@Bec_Temp"
            arrSqlParameter(12).SqlDbType = SqlDbType.VarChar
            arrSqlParameter(12).Size = 5
            arrSqlParameter(12).Direction = ParameterDirection.Input
            arrSqlParameter(12).Value = objBLImpoBE.Bec_Temp

            arrSqlParameter(13) = New SqlParameter()
            arrSqlParameter(13).ParameterName = "@Bec_Imo"
            arrSqlParameter(13).SqlDbType = SqlDbType.VarChar
            arrSqlParameter(13).Size = 6
            arrSqlParameter(13).Direction = ParameterDirection.Input
            arrSqlParameter(13).Value = objBLImpoBE.Bec_Imo

            arrSqlParameter(14) = New SqlParameter()
            arrSqlParameter(14).ParameterName = "@Bec_Unno"
            arrSqlParameter(14).SqlDbType = SqlDbType.VarChar
            arrSqlParameter(14).Size = 6
            arrSqlParameter(14).Direction = ParameterDirection.Input
            arrSqlParameter(14).Value = objBLImpoBE.Bec_Unno

            arrSqlParameter(15) = New SqlParameter()
            arrSqlParameter(15).ParameterName = "@Bec_Talm"
            arrSqlParameter(15).SqlDbType = SqlDbType.Char
            arrSqlParameter(15).Size = 3
            arrSqlParameter(15).Direction = ParameterDirection.Input
            arrSqlParameter(15).Value = objBLImpoBE.Bec_Talm

            arrSqlParameter(16) = New SqlParameter()
            arrSqlParameter(16).ParameterName = "@Bec_ucre"
            arrSqlParameter(16).SqlDbType = SqlDbType.VarChar
            arrSqlParameter(16).Size = 15
            arrSqlParameter(16).Direction = ParameterDirection.Input
            arrSqlParameter(16).Value = objBLImpoBE.Ucre


            '-------------------------------------------------------------------

            arrSqlParameter(17) = New SqlParameter()
            arrSqlParameter(17).ParameterName = "@Bec_LineIni"
            arrSqlParameter(17).SqlDbType = SqlDbType.VarChar
            arrSqlParameter(17).Size = 3
            arrSqlParameter(17).Direction = ParameterDirection.Input
            arrSqlParameter(17).Value = objBLImpoBE.Bec_LineIni

            arrSqlParameter(18) = New SqlParameter()
            arrSqlParameter(18).ParameterName = "@Bec_LineStock"
            arrSqlParameter(18).SqlDbType = SqlDbType.VarChar
            arrSqlParameter(18).Size = 3
            arrSqlParameter(18).Direction = ParameterDirection.Input
            arrSqlParameter(18).Value = objBLImpoBE.Bec_LineStock

            arrSqlParameter(19) = New SqlParameter()
            arrSqlParameter(19).ParameterName = "@Bec_TipoPaq"
            arrSqlParameter(19).SqlDbType = SqlDbType.VarChar
            arrSqlParameter(19).Size = 15
            arrSqlParameter(19).Direction = ParameterDirection.Input
            arrSqlParameter(19).Value = objBLImpoBE.Bec_TipoPaq

            arrSqlParameter(20) = New SqlParameter()
            arrSqlParameter(20).ParameterName = "@Bec_Cantidad"
            arrSqlParameter(20).SqlDbType = SqlDbType.Int
            arrSqlParameter(20).Direction = ParameterDirection.Input
            arrSqlParameter(20).Value = objBLImpoBE.Bec_Cantidad

            arrSqlParameter(21) = New SqlParameter()
            arrSqlParameter(21).ParameterName = "@Bec_Unid"
            arrSqlParameter(21).SqlDbType = SqlDbType.VarChar
            arrSqlParameter(21).Size = 10
            arrSqlParameter(21).Direction = ParameterDirection.Input
            arrSqlParameter(21).Value = objBLImpoBE.Bec_Unid

            arrSqlParameter(22) = New SqlParameter()
            arrSqlParameter(22).ParameterName = "@Bec_PesoBruto"
            arrSqlParameter(22).SqlDbType = SqlDbType.Float
            arrSqlParameter(22).Direction = ParameterDirection.Input
            arrSqlParameter(22).Value = objBLImpoBE.Bec_PesoBruto

            arrSqlParameter(23) = New SqlParameter()
            arrSqlParameter(23).ParameterName = "@Bec_PesoNeto"
            arrSqlParameter(23).SqlDbType = SqlDbType.Float
            arrSqlParameter(23).Direction = ParameterDirection.Input
            arrSqlParameter(23).Value = objBLImpoBE.Bec_PesoNeto

            arrSqlParameter(24) = New SqlParameter()
            arrSqlParameter(24).ParameterName = "@Bec_Carrier"
            arrSqlParameter(24).SqlDbType = SqlDbType.VarChar
            arrSqlParameter(24).Size = 15
            arrSqlParameter(24).Direction = ParameterDirection.Input
            arrSqlParameter(24).Value = objBLImpoBE.Bec_Carrier

            arrSqlParameter(25) = New SqlParameter()
            arrSqlParameter(25).ParameterName = "@Bec_Shipper"
            arrSqlParameter(25).SqlDbType = SqlDbType.VarChar
            arrSqlParameter(25).Size = 15
            arrSqlParameter(25).Direction = ParameterDirection.Input
            arrSqlParameter(25).Value = objBLImpoBE.Bec_Shipper

            arrSqlParameter(26) = New SqlParameter()
            arrSqlParameter(26).ParameterName = "@Bec_Obs"
            arrSqlParameter(26).SqlDbType = SqlDbType.VarChar
            arrSqlParameter(26).Size = 255
            arrSqlParameter(26).Direction = ParameterDirection.Input
            arrSqlParameter(26).Value = objBLImpoBE.Bec_Obs

            arrSqlParameter(27) = New SqlParameter()
            arrSqlParameter(27).ParameterName = "@Bec_Esta"
            arrSqlParameter(27).SqlDbType = SqlDbType.VarChar
            arrSqlParameter(27).Size = 1
            arrSqlParameter(27).Direction = ParameterDirection.Input
            arrSqlParameter(27).Value = objBLImpoBE.Bec_Esta

            arrSqlParameter(28) = New SqlParameter()
            arrSqlParameter(28).ParameterName = "@Bec_EstaTrans"
            arrSqlParameter(28).SqlDbType = SqlDbType.VarChar
            arrSqlParameter(28).Size = 15
            arrSqlParameter(28).Direction = ParameterDirection.Input
            arrSqlParameter(28).Value = objBLImpoBE.Bec_EstaTrans

            'id
            arrSqlParameter(29) = New SqlParameter()
            arrSqlParameter(29).ParameterName = "@Bec_ID"
            arrSqlParameter(29).SqlDbType = SqlDbType.Int
            arrSqlParameter(29).Direction = ParameterDirection.Input
            arrSqlParameter(29).Value = objBLImpoBE.ID



            Dim oDatos As New AccesoDatos()

            oDatos.EjecutaSP("SP_BlsContenedores_Ins", bExito, sMensaje, arrSqlParameter)

            Return bExito

        Catch ex As Exception
            Throw
        End Try

    End Function

    Public Function InsertarBlMercaderia(ByVal objBLImpoBE As BillOfLadingImpoBE, ByRef bExito As Boolean, ByRef sMensaje As String) As Boolean

        Dim arrSqlParameter(15) As SqlParameter

        Try

            arrSqlParameter(0) = New SqlParameter()
            arrSqlParameter(0).ParameterName = "@Bec_Kvje"
            arrSqlParameter(0).SqlDbType = SqlDbType.Int
            arrSqlParameter(0).Direction = ParameterDirection.Input
            arrSqlParameter(0).Value = objBLImpoBE.KVJE

            arrSqlParameter(1) = New SqlParameter()
            arrSqlParameter(1).ParameterName = "@Bec_Kbli"
            arrSqlParameter(1).SqlDbType = SqlDbType.Int
            arrSqlParameter(1).Direction = ParameterDirection.Input
            arrSqlParameter(1).Value = objBLImpoBE.KBLM

            arrSqlParameter(2) = New SqlParameter()
            arrSqlParameter(2).ParameterName = "@TOPE"
            arrSqlParameter(2).SqlDbType = SqlDbType.Char
            arrSqlParameter(2).Size = 1
            arrSqlParameter(2).Direction = ParameterDirection.Input
            arrSqlParameter(2).Value = objBLImpoBE.TOPE

            arrSqlParameter(3) = New SqlParameter()
            arrSqlParameter(3).ParameterName = "@Bef_Item"
            arrSqlParameter(3).SqlDbType = SqlDbType.Int
            arrSqlParameter(3).Direction = ParameterDirection.Input
            arrSqlParameter(3).Value = objBLImpoBE.Bef_Item

            arrSqlParameter(4) = New SqlParameter()
            arrSqlParameter(4).ParameterName = "@Bef_Desc"
            arrSqlParameter(4).SqlDbType = SqlDbType.VarChar
            arrSqlParameter(4).Size = 32
            arrSqlParameter(4).Direction = ParameterDirection.Input
            arrSqlParameter(4).Value = objBLImpoBE.Bef_Desc

            arrSqlParameter(5) = New SqlParameter()
            arrSqlParameter(5).ParameterName = "@Bem_Prod"
            arrSqlParameter(5).SqlDbType = SqlDbType.VarChar
            arrSqlParameter(5).Size = 32
            arrSqlParameter(5).Direction = ParameterDirection.Input
            arrSqlParameter(5).Value = objBLImpoBE.Bem_Prod

            arrSqlParameter(6) = New SqlParameter()
            arrSqlParameter(6).ParameterName = "@Bem_TipoBulto"
            arrSqlParameter(6).SqlDbType = SqlDbType.VarChar
            arrSqlParameter(6).Size = 20
            arrSqlParameter(6).Direction = ParameterDirection.Input
            arrSqlParameter(6).Value = objBLImpoBE.Bem_TipoBulto

            arrSqlParameter(7) = New SqlParameter()
            arrSqlParameter(7).ParameterName = "@Bem_Cant"
            arrSqlParameter(7).SqlDbType = SqlDbType.VarChar
            arrSqlParameter(7).Size = 20
            arrSqlParameter(7).Direction = ParameterDirection.Input
            arrSqlParameter(7).Value = objBLImpoBE.Bem_Cant

            arrSqlParameter(8) = New SqlParameter()
            arrSqlParameter(8).ParameterName = "@Bem_ParAran"
            arrSqlParameter(8).SqlDbType = SqlDbType.VarChar
            arrSqlParameter(8).Size = 20
            arrSqlParameter(8).Direction = ParameterDirection.Input
            arrSqlParameter(8).Value = objBLImpoBE.Bem_ParAran

            arrSqlParameter(9) = New SqlParameter()
            arrSqlParameter(9).ParameterName = "@Bem_PesoBruto"
            arrSqlParameter(9).SqlDbType = SqlDbType.VarChar
            arrSqlParameter(9).Size = 20
            arrSqlParameter(9).Direction = ParameterDirection.Input
            arrSqlParameter(9).Value = objBLImpoBE.Bem_PesoBruto

            arrSqlParameter(10) = New SqlParameter()
            arrSqlParameter(10).ParameterName = "@Bem_Total"
            arrSqlParameter(10).SqlDbType = SqlDbType.VarChar
            arrSqlParameter(10).Size = 20
            arrSqlParameter(10).Direction = ParameterDirection.Input
            arrSqlParameter(10).Value = objBLImpoBE.Bem_Total

            arrSqlParameter(11) = New SqlParameter()
            arrSqlParameter(11).ParameterName = "@Bem_Volumen"
            arrSqlParameter(11).SqlDbType = SqlDbType.VarChar
            arrSqlParameter(11).Size = 20
            arrSqlParameter(11).Direction = ParameterDirection.Input
            arrSqlParameter(11).Value = objBLImpoBE.Bem_Volumen

            arrSqlParameter(12) = New SqlParameter()
            arrSqlParameter(12).ParameterName = "@Bem_MarcaNum"
            arrSqlParameter(12).SqlDbType = SqlDbType.VarChar
            arrSqlParameter(12).Size = 20
            arrSqlParameter(12).Direction = ParameterDirection.Input
            arrSqlParameter(12).Value = objBLImpoBE.Bem_MarcaNum

            arrSqlParameter(13) = New SqlParameter()
            arrSqlParameter(13).ParameterName = "@Bem_Est"
            arrSqlParameter(13).SqlDbType = SqlDbType.VarChar
            arrSqlParameter(13).Size = 1
            arrSqlParameter(13).Direction = ParameterDirection.Input
            arrSqlParameter(13).Value = objBLImpoBE.Bem_Est

            arrSqlParameter(14) = New SqlParameter()
            arrSqlParameter(14).ParameterName = "@Bef_Ucre"
            arrSqlParameter(14).SqlDbType = SqlDbType.VarChar
            arrSqlParameter(14).Size = 32
            arrSqlParameter(14).Direction = ParameterDirection.Input
            arrSqlParameter(14).Value = objBLImpoBE.Ucre

            arrSqlParameter(15) = New SqlParameter()
            arrSqlParameter(15).ParameterName = "@Bef_Umod"
            arrSqlParameter(15).SqlDbType = SqlDbType.VarChar
            arrSqlParameter(15).Size = 15
            arrSqlParameter(15).Direction = ParameterDirection.Input
            arrSqlParameter(15).Value = objBLImpoBE.Umod


            Dim oDatos As New AccesoDatos()

            oDatos.EjecutaSP("SP_BlsMercaderia_Ins", bExito, sMensaje, arrSqlParameter)

            Return bExito

        Catch ex As Exception
            Throw
        End Try

    End Function

    Public Function ConsultarBLImportacion(ByVal objBLImpoBE As BillOfLadingImpoBE, ByRef dt As DataTable, ByRef strMensaje As String) As List(Of BillOfLadingImpoBE)

        Dim sqlListar As String
        Dim objConsultaBLImpo As New List(Of BillOfLadingImpoBE)
        Dim objBlImportacionBe As BillOfLadingImpoBE = Nothing
        Dim arrSqlParameter(3) As SqlParameter
        Dim ds As DataSet
        'Dim dt As DataTable = Nothing

        Dim objDatos As New AccesoDatos()
        Dim blnExito As Boolean
        'Dim strMensaje As String = String.Empty
        Dim intI As Integer = 0

        Try

            sqlListar = "SP_BLImpo_List"

            arrSqlParameter(0) = New SqlParameter("@Kvje", System.Data.SqlDbType.Int)
            arrSqlParameter(0).Value = objBLImpoBE.KVJE
            arrSqlParameter(1) = New SqlParameter("@PtoOrigen", System.Data.SqlDbType.VarChar)
            arrSqlParameter(1).Value = objBLImpoBE.Ptoo
            arrSqlParameter(2) = New SqlParameter("@Bl", System.Data.SqlDbType.VarChar)
            arrSqlParameter(2).Value = objBLImpoBE.Nume
            arrSqlParameter(3) = New SqlParameter("@Bl_Flag", System.Data.SqlDbType.Char)
            arrSqlParameter(3).Value = objBLImpoBE.Bli_Flag

            ds = objDatos.DevuelveDataSet(sqlListar, blnExito, strMensaje, arrSqlParameter)
            dt = ds.Tables(0)



            If dt.Rows.Count > 0 Then
                While intI < dt.Rows.Count
                    objBlImportacionBe = New BillOfLadingImpoBE()
                    objBlImportacionBe.KBLM = dt.Rows(intI).ItemArray(0).ToString
                    objBlImportacionBe.KVJE = dt.Rows(intI).ItemArray(1).ToString
                    objBlImportacionBe.desKVJE = dt.Rows(intI).ItemArray(2).ToString
                    objBlImportacionBe.Line = dt.Rows(intI).ItemArray(3).ToString
                    objBlImportacionBe.Condicion = dt.Rows(intI).ItemArray(4).ToString
                    objBlImportacionBe.Nume = dt.Rows(intI).ItemArray(5).ToString
                    objBlImportacionBe.Numero = dt.Rows(intI).ItemArray(6).ToString
                    objBlImportacionBe.Ptoo = dt.Rows(intI).ItemArray(7).ToString
                    objBlImportacionBe.Dpto = dt.Rows(intI).ItemArray(8).ToString
                    objBlImportacionBe.Ptoe = dt.Rows(intI).ItemArray(9).ToString
                    objBlImportacionBe.Dpte = dt.Rows(intI).ItemArray(10).ToString
                    objBlImportacionBe.Ddfi = dt.Rows(intI).ItemArray(11).ToString
                    objBlImportacionBe.Csne = dt.Rows(intI).ItemArray(12).ToString
                    objBlImportacionBe.EstadoDes = dt.Rows(intI).ItemArray(16).ToString
                    intI = intI + 1

                    objConsultaBLImpo.Add(objBlImportacionBe)
                End While
            Else
                strMensaje = 0
            End If

        Catch ex As Exception
            MsgBox(ex.Message, vbCritical, "Error del sistema")
            Return Nothing
            Exit Function
        End Try

        Return objConsultaBLImpo
    End Function

   
    Public Function EliminarBlImpo(ByVal objBlImpoBE As BillOfLadingImpoBE, ByRef bExito As Boolean, ByRef sMensaje As String) As Boolean

        Dim arrSqlParameter(1) As SqlParameter

        Try

            arrSqlParameter(0) = New SqlParameter()
            arrSqlParameter(0).ParameterName = "@Kvje"
            arrSqlParameter(0).SqlDbType = SqlDbType.Int
            arrSqlParameter(0).Direction = ParameterDirection.Input
            arrSqlParameter(0).Value = objBlImpoBE.KVJE


            arrSqlParameter(1) = New SqlParameter()
            arrSqlParameter(1).ParameterName = "@Kbl"
            arrSqlParameter(1).SqlDbType = SqlDbType.Int
            arrSqlParameter(1).Direction = ParameterDirection.Input
            arrSqlParameter(1).Value = objBlImpoBE.KBLM

            Dim oDatos As New AccesoDatos()

            oDatos.EjecutaSP("SP_BlsEliminarBLImpo", bExito, sMensaje, arrSqlParameter)

            Return bExito

        Catch ex As Exception
            MsgBox(ex.Message, vbCritical, "Error del sistema")
            Return Nothing
            Exit Function
        End Try

    End Function

    Public Function ObtieneBLImportacion_MaxCod(ByVal objBLImpoBE As BillOfLadingImpoBE, ByRef iCodMaximo As Integer) As List(Of BillOfLadingImpoBE)

        Dim sqlListar As String
        Dim objConsultaBLImpo As New List(Of BillOfLadingImpoBE)
        Dim objBlImportacionBe As BillOfLadingImpoBE = Nothing
        Dim arrSqlParameter(0) As SqlParameter
        Dim ds As DataSet
        Dim dt As DataTable

        Dim objDatos As New AccesoDatos()
        Dim blnExito As Boolean
        Dim strMensaje As String = String.Empty
        Dim intI As Integer = 0

        Try

            sqlListar = "SP_MaxCodBL"

            arrSqlParameter(0) = New SqlParameter("@TIPO", System.Data.SqlDbType.VarChar)
            arrSqlParameter(0).Value = objBLImpoBE.Tipo

            ds = objDatos.DevuelveDataSet(sqlListar, blnExito, strMensaje, arrSqlParameter)
            dt = ds.Tables(0)

            If dt.Rows.Count > 0 Then
                While intI < dt.Rows.Count
                    objBlImportacionBe = New BillOfLadingImpoBE()
                    objBlImportacionBe.KBLM = CType(dt.Rows(intI).ItemArray(0).ToString, Integer)

                    iCodMaximo = objBlImportacionBe.KBLM
                    intI = intI + 1

                    objConsultaBLImpo.Add(objBlImportacionBe)
                End While
            End If

        Catch ex As Exception
            MsgBox(ex.Message, vbCritical, "Error del sistema")
            Return Nothing
            Exit Function
        End Try

        Return objConsultaBLImpo


    End Function

    Public Function ObtieneBLImportacion(ByVal objBLImpoBE As BillOfLadingImpoBE, ByRef bExito As Boolean, ByRef sMensaje As String) As List(Of BillOfLadingImpoBE)

        Dim sqlListar As String
        Dim objConsultaBLImpo As New List(Of BillOfLadingImpoBE)
        Dim objBlImportacionBe As BillOfLadingImpoBE = Nothing
        Dim arrSqlParameter(1) As SqlParameter
        Dim ds As DataSet
        Dim dt As DataTable

        Dim objDatos As New AccesoDatos()
        Dim intI As Integer = 0

        Try

            sqlListar = "SP_1BlsCabecera_Obt"

            arrSqlParameter(0) = New SqlParameter("@Kvje", System.Data.SqlDbType.Int)
            arrSqlParameter(0).Value = objBLImpoBE.KVJE
            arrSqlParameter(1) = New SqlParameter("@NumBl", System.Data.SqlDbType.Int)
            arrSqlParameter(1).Value = objBLImpoBE.KBLM

            ds = objDatos.DevuelveDataSet(sqlListar, bExito, sMensaje, arrSqlParameter)
            dt = ds.Tables(0)




            If dt.Rows.Count > 0 Then
                While intI < dt.Rows.Count
                    objBlImportacionBe = New BillOfLadingImpoBE()
                    objBlImportacionBe.KVJE = dt.Rows(intI).ItemArray(0).ToString 'Bli_Kvje
                    objBlImportacionBe.KBLM = dt.Rows(intI).ItemArray(1) 'Bli_Kbli
                    objBlImportacionBe.desKVJE = dt.Rows(intI).ItemArray(2).ToString 'Nav_Desc
                    objBlImportacionBe.Nume = dt.Rows(intI).ItemArray(3).ToString ' Bli_Nume
                    objBlImportacionBe.Tibl = dt.Rows(intI).ItemArray(4).ToString ' Bli_Tibl - tipo de BL
                    objBlImportacionBe.Tg1_Desc = dt.Rows(intI).ItemArray(5).ToString 'Tg1_Desc
                    objBlImportacionBe.Femi = dt.Rows(intI).ItemArray(6).ToString 'Bli_Femi
                    objBlImportacionBe.Lemi = dt.Rows(intI).ItemArray(7).ToString 'Bli_Lemi
                    objBlImportacionBe.Norig = dt.Rows(intI).ItemArray(8).ToString 'Bli_Norig
                    objBlImportacionBe.Fomt = dt.Rows(intI).ItemArray(9).ToString 'Bli_Fomt
                    objBlImportacionBe.Agge = dt.Rows(intI).ItemArray(10).ToString 'bli_Agge
                    objBlImportacionBe.Tipo = dt.Rows(intI).ItemArray(11).ToString 'Ent_Rsoc
                    objBlImportacionBe.Agdo = dt.Rows(intI).ItemArray(12).ToString 'bli_Agdo ' agente documentario
                    objBlImportacionBe.Agm_Desc = dt.Rows(intI).ItemArray(13).ToString 'Agm_Desc
                    objBlImportacionBe.Line = dt.Rows(intI).ItemArray(14).ToString 'bli_Line
                    objBlImportacionBe.Agg_Line = dt.Rows(intI).ItemArray(15).ToString 'Agg_Line
                    objBlImportacionBe.Serv = dt.Rows(intI).ItemArray(16).ToString 'Bli_Serv
                    objBlImportacionBe.Ser_Desc = dt.Rows(intI).ItemArray(17).ToString 'Ser_Desc
                    objBlImportacionBe.Ptoo = dt.Rows(intI).ItemArray(18).ToString 'Cod_Pto_origen
                    objBlImportacionBe.Dpto = dt.Rows(intI).ItemArray(19).ToString 'Desc_Pto_origen
                    objBlImportacionBe.Ptoe = dt.Rows(intI).ItemArray(20).ToString 'Cod_Pto_emb
                    objBlImportacionBe.Dpte = dt.Rows(intI).ItemArray(21).ToString 'Desc_Pto_emb
                    objBlImportacionBe.Ptod = dt.Rows(intI).ItemArray(22).ToString 'Cod_Pto_desc
                    objBlImportacionBe.Dptd = dt.Rows(intI).ItemArray(23).ToString 'Desc_Pto_desc
                    objBlImportacionBe.Dfin = dt.Rows(intI).ItemArray(24).ToString 'Cod_Pto_dest_final
                    objBlImportacionBe.Ddfi = dt.Rows(intI).ItemArray(25).ToString 'Desc_Pto_dest_final
                    objBlImportacionBe.Agad = dt.Rows(intI).ItemArray(26).ToString 'Agent_aduana
                    objBlImportacionBe.Agad_Desc = dt.Rows(intI).ItemArray(37).ToString 'Agent_aduana descripcion
                    objBlImportacionBe.OpeLog = dt.Rows(intI).ItemArray(27).ToString 'Agent_log
                    objBlImportacionBe.Emba = dt.Rows(intI).ItemArray(28).ToString 'cod_emb
                    objBlImportacionBe.desc_cod_emb = dt.Rows(intI).ItemArray(29).ToString 'desc_cod_emb
                    objBlImportacionBe.Csne = dt.Rows(intI).ItemArray(30).ToString 'cod_cons
                    objBlImportacionBe.desc_cod_cons = dt.Rows(intI).ItemArray(31).ToString 'desc_cod_cons
                    objBlImportacionBe.Noti = dt.Rows(intI).ItemArray(32).ToString 'cod_not
                    objBlImportacionBe.desc_cod_not = dt.Rows(intI).ItemArray(33).ToString 'desc_cod_not

                    objBlImportacionBe.Ent_ObsEmb = dt.Rows(intI).ItemArray(35).ToString
                    objBlImportacionBe.Ent_ObsCons = dt.Rows(intI).ItemArray(36).ToString
                    objBlImportacionBe.Ent_ObsDoc = dt.Rows(intI).ItemArray(37).ToString
                    objBlImportacionBe.Bli_Flag = dt.Rows(intI).ItemArray(38).ToString

                    objBlImportacionBe.CodPto_Desc1 = dt.Rows(intI).ItemArray(39).ToString
                    objBlImportacionBe.CodPto_Desc2 = dt.Rows(intI).ItemArray(40).ToString
                    objBlImportacionBe.Pto_Desc1 = dt.Rows(intI).ItemArray(41).ToString
                    objBlImportacionBe.Pto_Desc2 = dt.Rows(intI).ItemArray(42).ToString

                    objBlImportacionBe.Bli_Fvb = dt.Rows(intI).ItemArray(43).ToString

                    intI = intI + 1

                    objConsultaBLImpo.Add(objBlImportacionBe)
                End While
            End If

        Catch ex As Exception
            MsgBox(ex.Message, vbCritical, "Error del sistema")
            Return Nothing
            Exit Function
        End Try

        Return objConsultaBLImpo
    End Function

    Public Function ObtieneBLImpMercaderiaCab(ByVal objBLImpoBE As BillOfLadingImpoBE, ByRef bExito As Boolean, ByRef sMensaje As String) As List(Of BillOfLadingImpoBE)

        Dim sqlListar As String
        Dim objConsultaBLImpo As New List(Of BillOfLadingImpoBE)
        Dim objBlImportacionBe As BillOfLadingImpoBE = Nothing
        Dim arrSqlParameter(1) As SqlParameter
        Dim ds As DataSet
        Dim dt As DataTable

        Dim objDatos As New AccesoDatos()
        Dim intI As Integer = 0

        Try

            sqlListar = "SP_2BlsMercaderia_Obt"

            arrSqlParameter(0) = New SqlParameter("@Kvje", System.Data.SqlDbType.Int)
            arrSqlParameter(0).Value = objBLImpoBE.KVJE
            arrSqlParameter(1) = New SqlParameter("@NumBl", System.Data.SqlDbType.Int)
            arrSqlParameter(1).Value = objBLImpoBE.KBLM

            ds = objDatos.DevuelveDataSet(sqlListar, bExito, sMensaje, arrSqlParameter)
            dt = ds.Tables(0)




            If dt.Rows.Count > 0 Then
                While intI < dt.Rows.Count
                    objBlImportacionBe = New BillOfLadingImpoBE()
                    objBlImportacionBe.KVJE = dt.Rows(intI).ItemArray(0).ToString 'Bli_Kvje
                    objBlImportacionBe.KBLM = dt.Rows(intI).ItemArray(1) 'Bli_Kbli
                    objBlImportacionBe.Bem_Prod = dt.Rows(intI).ItemArray(2).ToString 'Nav_Desc
                    objBlImportacionBe.Bem_TipoBulto = dt.Rows(intI).ItemArray(3).ToString ' Bli_Nume
                    objBlImportacionBe.Bem_Cant = dt.Rows(intI).ItemArray(4).ToString ' Bli_Tibl - tipo de BL
                    objBlImportacionBe.Bem_ParAran = dt.Rows(intI).ItemArray(5).ToString 'Tg1_Desc
                    objBlImportacionBe.Bem_PesoBruto = dt.Rows(intI).ItemArray(6).ToString 'Bli_Femi
                    objBlImportacionBe.Bem_Total = dt.Rows(intI).ItemArray(7).ToString 'Bli_Lemi
                    objBlImportacionBe.Bem_Volumen = dt.Rows(intI).ItemArray(8).ToString 'Bli_Norig
                    objBlImportacionBe.Bem_MarcaNum = dt.Rows(intI).ItemArray(9).ToString 'Bli_Fomt
                    objBlImportacionBe.Bem_Est = dt.Rows(intI).ItemArray(10).ToString 'bli_Agge

                    intI = intI + 1

                    objConsultaBLImpo.Add(objBlImportacionBe)
                End While
            End If

        Catch ex As Exception
            MsgBox(ex.Message, vbCritical, "Error del sistema")
            Return Nothing
            Exit Function
        End Try

        Return objConsultaBLImpo
    End Function

    Public Function ObtieneBLImpMercaderiaDet(ByVal objBLImpoBE As BillOfLadingImpoBE, ByRef dt As DataTable, ByRef bExito As Boolean, ByRef sMensaje As String) As List(Of BillOfLadingImpoBE)

        Dim sqlListar As String
        Dim objConsultaBLImpo As New List(Of BillOfLadingImpoBE)
        Dim objBlImportacionBe As BillOfLadingImpoBE = Nothing
        Dim arrSqlParameter(1) As SqlParameter
        Dim ds As DataSet
        'Dim dt As DataTable

        Dim objDatos As New AccesoDatos()
        Dim intI As Integer = 0

        Try

            sqlListar = "SP_2BlsMercaderiaDet_Obt"

            arrSqlParameter(0) = New SqlParameter("@Kvje", System.Data.SqlDbType.Int)
            arrSqlParameter(0).Value = objBLImpoBE.KVJE
            arrSqlParameter(1) = New SqlParameter("@NumBl", System.Data.SqlDbType.Int)
            arrSqlParameter(1).Value = objBLImpoBE.KBLM

            ds = objDatos.DevuelveDataSet(sqlListar, bExito, sMensaje, arrSqlParameter)
            dt = ds.Tables(0)


        Catch ex As Exception
            MsgBox(ex.Message, vbCritical, "Error del sistema")
            Return Nothing
            Exit Function
        End Try

        Return objConsultaBLImpo
    End Function

    Public Function ObtieneBLImpFlete(ByVal objBLImpoBE As BillOfLadingImpoBE, ByRef dt As DataTable, ByRef bExito As Boolean, ByRef sMensaje As String) As List(Of BillOfLadingImpoBE)

        Dim sqlListar As String
        Dim objConsultaBLImpo As New List(Of BillOfLadingImpoBE)
        Dim objBlImportacionBe As BillOfLadingImpoBE = Nothing
        Dim arrSqlParameter(1) As SqlParameter
        Dim ds As DataSet
        'Dim dt As DataTable

        Dim objDatos As New AccesoDatos()
        Dim intI As Integer = 0

        Try

            sqlListar = "SP_2BlsFleteDet_Obt"

            arrSqlParameter(0) = New SqlParameter("@Kvje", System.Data.SqlDbType.Int)
            arrSqlParameter(0).Value = objBLImpoBE.KVJE
            arrSqlParameter(1) = New SqlParameter("@NumBl", System.Data.SqlDbType.Int)
            arrSqlParameter(1).Value = objBLImpoBE.KBLM

            ds = objDatos.DevuelveDataSet(sqlListar, bExito, sMensaje, arrSqlParameter)
            dt = ds.Tables(0)


        Catch ex As Exception
            MsgBox(ex.Message, vbCritical, "Error del sistema")
            Return Nothing
            Exit Function
        End Try

        Return objConsultaBLImpo
    End Function

    Public Function ObtieneBLImpContenedor(ByVal objBLImpoBE As BillOfLadingImpoBE, ByRef dt As DataTable, ByRef bExito As Boolean, ByRef sMensaje As String) As List(Of BillOfLadingImpoBE)

        Dim sqlListar As String
        Dim objConsultaBLImpo As New List(Of BillOfLadingImpoBE)
        Dim objBlImportacionBe As BillOfLadingImpoBE = Nothing
        Dim arrSqlParameter(1) As SqlParameter
        Dim ds As DataSet


        Dim objDatos As New AccesoDatos()
        Dim intI As Integer = 0

        Try

            sqlListar = "SP_2BlsContenedorDet_Obt"

            arrSqlParameter(0) = New SqlParameter("@Kvje", System.Data.SqlDbType.Int)
            arrSqlParameter(0).Value = objBLImpoBE.KVJE
            arrSqlParameter(1) = New SqlParameter("@NumBl", System.Data.SqlDbType.Int)
            arrSqlParameter(1).Value = objBLImpoBE.KBLM

            ds = objDatos.DevuelveDataSet(sqlListar, bExito, sMensaje, arrSqlParameter)
            dt = ds.Tables(0)


        Catch ex As Exception
            MsgBox(ex.Message, vbCritical, "Error del sistema")
            Return Nothing
            Exit Function
        End Try

        Return objConsultaBLImpo
    End Function


    Public Function ConsultarBLImportacionDesglose(ByVal objBLImpoBE As BillOfLadingImpoBE) As BillOfLadingImpoBE

        Dim sqlListar As String
        Dim objConsultaBLImpo As New List(Of BillOfLadingImpoBE)
        Dim objBlImportacionBe As BillOfLadingImpoBE = Nothing
        Dim arrSqlParameter(1) As SqlParameter
        Dim ds As DataSet
        Dim dt As DataTable

        Dim objDatos As New AccesoDatos()
        Dim blnExito As Boolean
        Dim strMensaje As String = String.Empty
        Dim intI As Integer = 0

        Try

            sqlListar = "SP_BLImpoDesglose_List"

            arrSqlParameter(0) = New SqlParameter("@Kvje", System.Data.SqlDbType.Int)
            arrSqlParameter(0).Value = objBLImpoBE.KVJE
            arrSqlParameter(1) = New SqlParameter("@KBLi", System.Data.SqlDbType.Int)
            arrSqlParameter(1).Value = objBLImpoBE.KBLM

            ds = objDatos.DevuelveDataSet(sqlListar, blnExito, strMensaje, arrSqlParameter)
            dt = ds.Tables(0)


            If dt.Rows.Count > 0 Then
                'While intI < dt.Rows.Count
                objBlImportacionBe = New BillOfLadingImpoBE()


                objBlImportacionBe.KVJE = dt.Rows(0).ItemArray(0).ToString
                objBlImportacionBe.desKVJE = dt.Rows(0).ItemArray(1).ToString
                objBlImportacionBe.Csne = dt.Rows(0).ItemArray(2).ToString
                objBlImportacionBe.desc_cod_cons = dt.Rows(0).ItemArray(3).ToString
                objBlImportacionBe.KBLM = dt.Rows(0).ItemArray(4).ToString
                objBlImportacionBe.Nume = dt.Rows(0).ItemArray(5).ToString
                objBlImportacionBe.Bec_Peso = dt.Rows(0).ItemArray(6).ToString
                objBlImportacionBe.CantContenedores = CType(dt.Rows(0).ItemArray(7), Integer)
                objBlImportacionBe.EstadoDes = dt.Rows(0).ItemArray(8).ToString

                'intI = intI + 1

                'objConsultaBLImpo.Add(objBlImportacionBe)
                'End While
            End If

        Catch ex As Exception
            MsgBox(ex.Message, vbCritical, "Error del sistema")
            Return Nothing
            Exit Function
        End Try

        Return objBlImportacionBe
    End Function



End Class
